DB2获得表内主键 Get PrimaryKeys

Categories: Database; Tagged with: ; @ October 3rd, 2010 14:50

SQL:

SELECT * FROM SYSIBM.SYSCOLUMNS WHERE TBCREATOR NOT LIKE ‘SYS%’ AND TBNAME = ‘TABLENAME‘ AND KEYSEQ > 0 ORDER BY KEYSEQ ASC;

Use in jdbc:

resultSet = statement.executeQuery(sql);
while(resultSet.next()) {
                System.out.println(resultSet.getString("NAME"));
}

 

See: http://database.ittoolbox.com/groups/technical-functional/db2-l/how-to-find-a-primary-keys-and-foreign-keys-in-a-db2-table-268468?exp=1

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.